<%--<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/layout/tag.jsp"%>
<script type="text/javascript">
	$(document).ready( 
		function() {
			//事件注册.
			$("#saveBtn").click(saveMember);
			$("#returnBtn").click(returnToList);
			$("#showBookDlgBtn").click(addBook);
			
			$("img[name='delImg']").each(
				function(index) {
					$(this).click(deleteBook);
				}
			);
			
			//设置左菜单对应菜单CSS为选中状态.
			changeToActiveCss("menu_3010");
			
			//消息显示.
			var msg = '<c:out value="${msg}"/>';
			if (msg != "") {
				alert(msg);
			}
		}
	);
	
	function saveMember() {
		if(confirm("确定要保存订单信息吗?")) {
			var action = $("#editForm").attr("action");
			action += "?oper=" + '<c:out value="${oper}"/>';
			$("#editForm").attr("action", action);
			$("#editForm").submit();
		}
	}
	
	function returnToList() {
		window.location.href='${pageContext.request.contextPath}/order/enterOrderList.do';
	}
	
	function addBook() {
		showDialog("bookSelect");
		var bookIds = $("#dlgReturn").val();
		$("#dlgReturn").val("");
		if (bookIds != "") {
			var orderId = $("#sysId").val();
			var strData = "orderId=" + orderId + "&bookIds=" + bookIds;
			$.ajax({
				type:"post",
				url:"${pageContext.request.contextPath}/order/addBook.do",
				context:this,
				dataType:"json",
				data:strData,
				success:addBookCallBack,
				error:function(){alert("发生了错误.");},
			});
		} 
	}
	
	function addBookCallBack(result) {
		if (result.status == "OK") {
			var bookList = result.orderGoodsList;
			for (var i=0; i<bookList.length; i++) {
				var goods = bookList[i].goods; 
				var strTr = "<tr sysid=" + bookList[i].sysId + ">" +
							"<td><img name='delImg' title='没有存书时,电话确认后在这里删除.' src='${pageContext.request.contextPath}/images/btn_cross.png' alt=''/></td>" +
							"<td>" + goods.name + "</td>" +
							"<td>" + goods.isbn + "</td>" +
							"<td>" + goods.innerCode + "</td>" +
							"<td>" + goods.innerSerial + "</td>" +
							"<td>" + goods.publish + "</td>" +
							"<td>" + goods.price + "</td>" +
							"<td>" + goods.buyPrice + "</td></tr>";
				var tr = $("#booksTable").append(strTr);
				$("img[name='delImg']:last").click(deleteBook);
			}
		} 
		
		alert(result.msg);
	}
	
	function deleteBook() {
		var sysId = $(this).parents("tr").attr("sysid");
		if (sysId != undefined && $.trim(sysId) != "") {
			if(!confirm("确定要从该订单删除图书信息吗?")) {
				return false;
			}
		
			$.ajax({
				type:"post",
				url:"${pageContext.request.contextPath}/order/deleteBook.do",
				context:this,
				dataType:"json",
				data:"sysId=" + sysId,
				success:deleteBookCallBack,
				error:function(){alert("发生了错误.");},
			});
		} else {
			$(this).parents("tr").remove();
		}
	}
	
	function deleteBookCallBack(result) {
		if (result.status == "OK") {
			$(this).parents("tr").remove();
			alert(result.msg);
		} else {
			alert(result.msg);
		}
	}
	
</script>
<input type="hidden" id="dlgReturn" name="dlgReturn" value=""/>
<div id="content_right">
	<div style="width:100%;height:35px;line-height:35px;text-align:left;background-color:#F5FAFA;font-weight:bold; ">订单 > 租书订单管理 > 租书订单修改</div>
	<div>
		<div id="tabBar">
			<span class="curentTab">订单总览</span>
		</div>
		<div class="buttons" style="float:right; ">
			<a id="saveBtn" href="#">
				<img src="../images/btn_apply.png" alt=""/> 
				保存
			</a>
			<a id="returnBtn" href="#">
				<img src="../images/btn_apply.png" alt=""/> 
				返回列表
			</a>
		</div>
	</div>
	<div id="editContainer">
		<div id="baseInfo" class="editPanel">
			<span class="title">基本信息</span>
			<div style="clear:both;"></div>
			<div style="float:left; width:100%;margin-left:10px;">
			<form:form id="editForm" action="${pageContext.request.contextPath}/order/saveOrder.do" commandName="order">
				<form:hidden path="sysId" />
				<table class="infoTable">
					<tr>
						<th>订单编号：</th>
						<td>${order.code}</td>
						<th>会员名：</th>
						<td>${order.member.name}</td>
					</tr>
					<tr>
						<th>订单状态：</th>
						<td>${order.statusStr}</td>
						<th>收货人姓名：</th>
						<td>${order.recName}</td>
					</tr>
					<tr>
						<th>下单日期：</th>
						<td>${order.showTime}</td>
						<th>收货人电话：</th>
						<td>${order.recPhone}</td>
					</tr>
					<tr>
						<th>期望送货日：</th>
						<td>${order.hopeDate}</td>
						<th>收货人地址：</th>
						<td>${order.address}</td>
					</tr>
					<tr>
						<th>送货日：</th>
						<td><form:input path="sendDate" cssStyle="width:100px; " title="默认为期望送货日,当用户未设置时默认为下单日期的下一个工作日." maxlength="10"/></td>
						<th>送货员：</th>
						<td><form:input path="sendName" cssStyle="width:100px; " maxlength="8"/></td>
					</tr>
					<tr>
						<th>订单备注：</th>
						<td></td>
					</tr>
				</table>
			</form:form>
			</div>
			<div style="clear:both;"></div>
		</div>
		
		<div id="relationInfo" class="editPanel" style="height:290px; ">
			<span class="title">图书列表</span>
			<div style="clear:both;"></div>
			<div style="float:left; width:870px;margin-left:10px;height:92%;overflow-y:scroll;overflow-x:hidden;border:1px solid white;">
				<table id="booksTable" class="relationTable">
					<tr>
						<th style="width:90px;">
							<div class="buttons" style="float:left; margin-left:5px;">
								<a id="showBookDlgBtn" href="#">
									<img src="../images/btn_apply.png" alt=""/> 
									添加
								</a>
							</div>
						</th>
						<th style="width:180px;">
							图书名
						</th>
						<th style="width:120px;">
							ISBN
						</th>
						<th style="width:60px;">
							内部编号
						</th>
						<th style="width:50px;">
							货架号
						</th>
						<th style="width:170px;">
							出版社
						</th>
						<th style="width:80px;">
							价格
						</th>
						<th style="width:80px;">
							购买价格
						</th>
					</tr>
					<c:forEach var="item" items="${goodsList}" varStatus="status">
					<tr sysid="${item.sysId}">
						<td><img name="delImg" title="没有存书时,电话确认后在这里删除." src="${pageContext.request.contextPath}/images/btn_cross.png" alt=""/></td>
						<td>${item.goods.name}</td>
						<td>${item.goods.isbn}</td>
						<td>${item.goods.innerCode}</td>
						<td>${item.goods.innerSerial}</td>
						<td>${item.goods.publish}</td>
						<td>${item.goods.price}</td>
						<td>${item.goods.buyPrice}</td>
					</tr>
					</c:forEach>
				</table>
				<div style="height:1px;clear:both;"></div>
			</div>
		</div>
		
	</div>
</div>
--%>